package com.project.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.project.entity.ProjectInfo;
import com.project.service.ProjectInfoService;
import com.project.service.Impl.ProjectInfoServiceImpl;

public class UpdateProServlet extends HttpServlet {
	ProjectInfoService impl = new ProjectInfoServiceImpl();
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		int id = Integer.parseInt(request.getParameter("id"));
		String name = request.getParameter("projectName");
		String star = request.getParameter("startDate");
		String end = request.getParameter("endDate");
		int status = Integer.parseInt(request.getParameter("staus"));
		ProjectInfo pro = new ProjectInfo(id, name, star, end, status);
		int line = impl.gai(pro);
		if(line>0) {
			response.sendRedirect("ProjectInfoServlet");
		}else {
			response.sendRedirect("gai.jsp");
		}
	}
}
